//
//  HSatisDetailTableViewCell.m
//  NursingManages
//
//  Created by Zhen Huang on 17/6/22.
//  Copyright © 2017年 huangzhen. All rights reserved.
//

#import "HSatisDetailTableViewCell.h"
#import "BigModel.h"
@implementation HSatisDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.selectButton];
        [self.contentView addSubview:self.ItemLabel];
        [self.contentView addSubview:self.textview];
        [self.contentView addSubview:self.dateButton];
        [self.contentView addSubview:self.chooseButton];
    }
    return self;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth - 20, 20)];
        _titleLabel.numberOfLines = 0;
        _titleLabel.font = [UIFont systemFontOfSize:16];
        
    }
    return _titleLabel;
}

- (UIButton *)selectButton
{
    if (!_selectButton) {
        _selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _selectButton.frame = CGRectMake(30, 10, 25, 25);
    }
    return _selectButton;
}
- (UILabel *)ItemLabel
{
    if (!_ItemLabel) {
        _ItemLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.selectButton.right + 10, 10, ScreenWidth - self.selectButton.right - 10, 30)];
    }
    return _ItemLabel;
}

- (UITextView *)textview
{
    if (!_textview) {
        _textview = [[UITextView alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth - 20, 35)];
        _textview.delegate = self;
        _textview.layer.borderWidth = 0.1;
        _textview.layer.cornerRadius = 6.0;
        _textview.layer.masksToBounds = YES ;

    }
    return _textview;
}
- (UIButton *)dateButton
{
    if (!_dateButton) {
        _dateButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _dateButton.frame = CGRectMake(10, 10, ScreenWidth-20, 30);
        _dateButton.backgroundColor = [UIColor whiteColor];
        _dateButton.layer.borderColor = [RGB(212,212,212) CGColor];
        _dateButton.layer.borderWidth = 0.3f;
        _dateButton.layer.masksToBounds = YES;
        _dateButton.layer.cornerRadius = 5;
        _dateButton.titleLabel.textAlignment = NSTextAlignmentLeft;
        [_dateButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _dateButton.titleLabel.font = [UIFont systemFontOfSize:16];
        
    }
    return _dateButton;
}

- (UIButton *)chooseButton
{
    if (!_chooseButton) {
        _chooseButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _chooseButton.frame = CGRectMake(10, 10, ScreenWidth-20, 30);
        _chooseButton.backgroundColor = [UIColor whiteColor];
        _chooseButton.layer.borderColor = [RGB(212,212,212) CGColor];
        _chooseButton.layer.borderWidth = 0.3f;
        _chooseButton.layer.masksToBounds = YES;
        _chooseButton.layer.cornerRadius = 5;
        _chooseButton.titleLabel.textAlignment = NSTextAlignmentLeft;
        [_chooseButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _chooseButton.titleLabel.font = [UIFont systemFontOfSize:16];
        
    }
    return _chooseButton;
}


- (void)cellWithData:(Model_Hr_SatCodeItem *)model
        hasItemArray:(BOOL)hasItemArray
                cell:(HSatisDetailTableViewCell *)cell
           headArray:(NSArray *)headArray
        indexSection:(NSInteger)indexSection
        score_method:(NSString *)score_method
{
    
    BigModel *bigModel = headArray[indexSection];
    
    if (hasItemArray == NO) {
        cell.selectButton.hidden = YES;
        cell.ItemLabel.hidden = YES;
        if ([score_method isEqualToString:@"4"]) {
            cell.textview.hidden = YES;
            cell.chooseButton.hidden = YES;
            cell.dateButton.hidden = NO;
        }else if ([score_method isEqualToString:@"2"]){
            cell.textview.hidden = NO;
            cell.dateButton.hidden = YES;
            cell.chooseButton.hidden = YES;
            cell.textview.text = bigModel.InformationText;
        }else if ([score_method isEqualToString:@"3"]) {
            cell.textview.hidden = YES;
            cell.chooseButton.hidden = NO;
            cell.dateButton.hidden = YES;

        }else {
            cell.textview.hidden = NO;
            cell.dateButton.hidden = YES;
            cell.chooseButton.hidden = YES;
            cell.textview.text = bigModel.InformationText;
        }
       
    }else {
        cell.dateButton.hidden = YES;
        cell.textview.hidden = YES;
        self.chooseButton.hidden = YES;
        cell.ItemLabel.hidden = NO;
        cell.selectButton.hidden = NO;
    }
    if (model.isSelected) {
        [self.selectButton setBackgroundImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateNormal];
    } else {
        [self.selectButton setBackgroundImage:[UIImage imageNamed:@"weixuanzhong"] forState:UIControlStateNormal];
    }

}
- (void)setUpcell:(HSatisDetailTableViewCell *)cell block: (void(^)(NSInteger ))callback
{
        
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
